import { WebGLRenderer } from 'three';
import { GLTF, GLTFLoader } from './Extension/GLTFLoader';
class ResLoader {
  private gltfLoader: GLTFLoader;
  constructor() {
    this.gltfLoader = new GLTFLoader();
  }

  /**
   * loadGLTF 加载GLTF
   */
  public loadGLTF(
    filePath: string,
    onProgress?: (event: ProgressEvent) => void
  ): Promise<GLTF> {
    return this.gltfLoader.loadAsync(filePath, onProgress);
  }
  /**
  * loadGLTF 加载GLTF
  */
  public loadGLTFPath(
    filePath: string,
    fileName: string,
    render: WebGLRenderer,
    onProgress?: (event: ProgressEvent) => void
  ): Promise<GLTF> {
    const loader = new GLTFLoader();
    loader.setPath(filePath);
    return loader.loadAsync(fileName, onProgress);
  }
}

export const _ResLoader = new ResLoader();
